package com.dabai.qrtools.adapter;

import android.graphics.Color;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.dabai.qrtools.R;

import java.util.List;

/**
 * Description : Other
 *
 * @author BAI
 */
public class ColorChooseAdapter extends BaseQuickAdapter<String, BaseViewHolder> {


    public ColorChooseAdapter(@Nullable List<String> data) {
        super(R.layout.item_color, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, String s) {
        int color = 0;
        try {
            color = Color.parseColor(s);
        }catch (Exception ignored){
        }

        baseViewHolder.setText(R.id.colorText, color == 0 ? "颜色解析错误":s);
        baseViewHolder.setBackgroundColor(R.id.colorText, color == 0 ? Color.parseColor("#CFD8DC") :Color.parseColor(s));
        baseViewHolder.setBackgroundColor(R.id.colorBack, color == 0 ? Color.parseColor("#CFD8DC") :Color.parseColor(s));

    }
}
